// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  return cloud.callFunction({
    name: "model_good",
    data: {
      op: "add",
      i_id: event.institution_id,
      price: event.price,
      number: event.number,
      name: event.name,
      title: event.title,
      img: event.img,
      description: event.description,
      tag: event.tag,
      type: event.type,
      status: event.status,
      order: event.order
    }
  }).then(res => {
    return cloud.callFunction({//获取商品信息
      name: "model_good",
      data: {
        op: "select",
        key: "_id",
        value: res.result._id
      }
    }).then(res => {
      return res.result.data
    })
  })
}